<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0,viewport-fit=cover">
    <!-- <meta name="viewport" content="width=device-width, initial-scale=1.0"> -->
    <title>平台首页</title>
    <link rel="stylesheet" type="text/css" href="../../css/vant.css">
    <script type="text/javascript" src="../../script/jquery.js"></script>
    <script type="text/javascript" src="../../script/vue.min.js"></script>
    <script type="text/javascript" src="../../script/vant.min.js"></script>
    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        .head {
            background-color: #fff !important;
        }

        .TitleText {
            color: #333 !important;
            font-size: 18px;
        }

        body {
            height: 100vh;
        }

        [v-cloak] {
            display: none !important;
        }

        .van-nav-bar .van-icon {
            color: #333 !important;
        }

        .van-nav-bar__text {
            color: #333 !important;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak>
        <div class="init-full">
            <van-nav-bar class="head head-index TopNav" left-arrow @click-left="GoBack">
                <template #title>
                    <span class="TitleText">{{TitleText}}</span>
                </template>
            </van-nav-bar>

            <!-- <iframe style="width:100vw;height: calc( 100vh - 62px )" :src="ShowPageUrl"></iframe> -->


        </div>
    </div>
</body>

<script type="text/javascript">
    var vm;
    apiready = function () {
        var browser = api.require('webBrowser');

        vm = new Vue({
            el: '#app',
            data: {
                ShowPageUrl: api.pageParam.TheUrl,
                TitleText: api.pageParam.TitleText,
                showPage: false,
            },
            created: function () {
                var that = this;

                console.log('sapi.pageParam', JSON.stringify(api.pageParam))
                // alert(that.ShowPageUrlO)

                var appTop = parseInt(api.safeArea.top);

                if (appTop) {
                    $('.TopNav').css({
                        'padding-top': appTop + 'px',
                        'height': appTop + 40 + 'px',
                        'line-height': '40px'
                    })
                }

                setTimeout(() => {
                    // console.log(JSON.stringify(that.judgeImg(that.ShowPageUrl)));
                    // api.openFrame({
                    //     name: 'page2',
                    //     url: that.judgeImg(that.ShowPageUrl),
                    //     rect: {
                    //         x: 0,
                    //         // y: 0,
                    //         y: parseInt(window.localStorage.getItem('safeAreaTop')) + 40,
                    //         w: 'auto',
                    //         h: 'auto'
                    //     },
                    //     pageParam: {
                    //         // name: 'test'
                    //     }
                    // });


                    browser.openView({
                        url: that.judgeImg(that.ShowPageUrl),
                        rect: {
                            x: 0,
                            y: parseInt(api.safeArea.top) + 40,
                            // y: 40,
                            w: 'auto',
                            h: 'auto'
                        }
                    }, function (ret, err) {
                        switch (ret.state) {
                            case 0:
                                break;
                            case 1:
                                break;
                            case 2:
                                break;
                            case 3:
                                break;
                            case 4:
                                break;
                            default:
                                break;
                        }
                    });

                }, 300)

            },
            methods: {
                judgeImg(data) {
                    var that = this
                    console.log('data', JSON.stringify(data))
                    if (data == null) {
                        return 'http://' + window.localStorage.getItem('serverIP') + that.spareImg
                    } else if (data.search(/^http:/) == -1 && data.search(/^https:/) == -1) {
                        return 'http://' + window.localStorage.getItem('serverIP') + data
                    } else {
                        return data
                    }
                    // return data
                },
                GoBack() {
                    api.closeWin()
                },
            }
        })
    };

    // window.onload = function () {
    //     if (location.href.indexOf('#reloaded') == -1) {
    //         location.href = location.href + "#reloaded";
    //         location.reload();
    //     }
    // }
</script>

</html>